$(function(){
	
	var myChart = echarts.init(document.getElementById('relation'));  
myChart.showLoading();
$.get('data/les-miserables.gexf', function (xml) {
    myChart.hideLoading();

    var graph = echarts.dataTool.gexf.parse(xml);
    var categories = [{name:'涉习事件'},{name:'任志强事件'},{name:'撞脸事件'},{name:'习出访'},{name:'十九大'},{name:'宁夏事件'},{name:'股灾事件'}];
    graph.nodes.forEach(function (node) {
        node.itemStyle = null;
        node.value = node.symbolSize;
        node.symbolSize /= 1.5;
        node.label = {
            normal: {
                show: node.symbolSize > 2
            }
        };
        node.category = node.attributes.modularity_class;
    });
    var option = {
    	color:['#70d9ff', '#e76258', '#4CE73C', '#1793fd', '#F2d703','#ff954d','#73fff1'],
        title: {
            subtext: 'Default layout',
            top: 'bottom',
            left: 'right'
        },
        tooltip: {},
        legend: [{
            show:false,
            textStyle:{
                color:'#fff',
                fontSize:20
            },
            // selectedMode: 'single',
            data: categories.map(function (a) {
                return a.name;
            })
        }],
        animationDuration: 1500,
        animationEasingUpdate: 'quinticInOut',
        series : [
            {
                name: '',
                type: 'graph',
                layout: 'none',
                data: graph.nodes,
                links: graph.links,
                categories: categories,
                roam: true,
                label: {
                    normal: {
                        position: 'right',
                        formatter: '{b}'
                    }
                },
                lineStyle: {
                    normal: {
                        color: 'source',
                        curveness: 0.3
                    }
                }
            }
        ]
    };

    myChart.setOption(option);
}, 'xml');
})